<template>
  <div class="cal">
    <van-nav-bar
      right-text="注册"
      left-arrow
      @click-left="onClickLeft"
      @click-right="onClickRight"
    />
    <div class="dv">
      <h1>密码登录</h1>
      <span> 短信验证码登录 ></span>
    </div>
    <van-form @submit="onSubmit">
      <van-cell-group inset>
        <van-field
          v-model="logins.mobile"
          name="用户名"
          placeholder="请输入手机号"
          :rules="[{ required: true, message: '请输入手机号' }]"
        />
        <van-field
          v-model="logins.password"
          type="password"
          name="密码"
          placeholder="密码"
          :rules="[{ required: true, message: '请填写密码' }]"
        />
      </van-cell-group>
      <p>
        <van-checkbox v-model="ckbox"
          >我已同意<span class="sp">用户协议</span>及<span class="sp">隐私条款</span>
        </van-checkbox>
      </p>
      <div style="margin: 16px">
        <van-button round block type="primary" native-type="submit"> 登录</van-button>
      </div>
      <p>忘记密码?</p>
      <div class="qqdv">
        <p>第三方登录</p>
        <van-icon name="qq" class="qq" />
      </div>
    </van-form>
  </div>
</template>

<script lang="ts" setup>
import { ref, reactive, toRefs } from 'vue'
// import { useStore } from 'vuex';
import { showToast } from 'vant';
import { useRouter, useRoute } from 'vue-router'
import { passwordlogin } from '../utils/app'
const router=useRouter()
const onClickLeft = () => history.back()
const onClickRight = () => showToast('按钮')
const username = ref('')
const password = ref('')
const ckbox = ref(false)
const logins = reactive({
  mobile: '13230000059',
  password: 'abc12345'
})
const onSubmit = () => {
  passwordlogin(logins).then((res) => {
    console.log(res)
    localStorage.setItem("token",res.data.data.token),
   router.push("/tab")
  })
}
</script>

<style lang="scss">
.dv {
  display: flex;
  width: 100%;
  justify-content: space-around;
  margin: 10px 0;
  span {
    margin: 18px 0;
  }
}
.sp {
  color: #1989fa;
}
.cal {
  position: relative;
  height: 100vh;
}
.qq {
  background: #1989fa;
  color: #fff;
  width: 45px;
  height: 45px;
  font-size: 35px;
  border-radius: 50%;
  line-height: 50px;
  text-align: center;
}
.qqdv {
  position: absolute;
  left: 145px;
  bottom: -23.86667vw;
}
</style>
